package com.source.sys.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.source.sys.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.source.sys.vo.RoleVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZZF
 * @since 2021-02-08
 */
public interface RoleMapper extends BaseMapper<Role> {
    /**
     * 逻辑删除角色
     * @param roleId
     * @return
     */

    @Update(value = "update sys_role set useable = 0 where rid = #{rid} and useable = 1")
    int logicDeleteRoleById(@Param("rid") String roleId);

    /**
     * 根据id修改名称
     * @param roleId
     * @param roleName
     * @return
     */
    @Update("update sys_role set rname = #{roleName} where rid = #{roleId}")
    int updateRoleNameByRid(@Param("roleId") String roleId,@Param("roleName") String roleName);

    /**
     * 模糊查询获取role
     * @param value
     * @param roleVoPage
     * @return
     */
    @Select("select * from sys_role where useable = 1 and concat(rid,rname) like '%${value}%'")
    Page<RoleVo> listRoleVoPageByLike(@Param("value") String value, Page<RoleVo> roleVoPage);

    /**
     * 查询role
     * @param roleVoPage
     * @return
     */
    @Select("select * from sys_role where useable = 1")
    Page<RoleVo> listRoleVoPage(Page<RoleVo> roleVoPage);


}